package cn.edu.jsu.nrs.util;
/**
 * 页面信息
 * @author:YYH
 * @date:2013-4-4 下午11:56:26
 * @update-date:2013-4-4 下午11:56:26
 * @version:
 * @project_name:NewsReleaseSystem_JiShou
 * @description:
 */
public class PageInfor {
	private int totalCount;// 总的记录数
	private int totalPage;// 总页数
	private int currentPage = 1;// 当前页,默认为1
	private int pageSize = 15;// 页面的大小
	private int priviousPage;
	private int nextPage;
	private int beginIndex;//分页记录开始索引

	

	/**
	 * 
	 * @param totalCount
	 *            总记录数
	 * @param pageSize
	 *            页面的大小
	 * @param page
	 */
	public PageInfor(int totalCount, int pageSize, int page) {
		this.totalCount = totalCount;
		this.pageSize = pageSize;
		if ((totalCount % pageSize) == 0) {
			this.totalPage = totalCount / pageSize;
		} else {
			this.totalPage = (totalCount / pageSize) + 1;
		}

		setCurrentPage(page);

	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	/**
	 * 设置当前页
	 * 
	 * @param currentPage
	 */
	public void setCurrentPage(int currentPage) {
		if (currentPage > totalPage) {// 如果当前页大于总页数
			this.currentPage = totalPage;
		} else if (currentPage < 1) {// 如果当前页小于1
			this.currentPage = 1;
		} else {
			this.currentPage = currentPage;
		}

	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	
	public int getBeginIndex() {
		return beginIndex;
	}

	public void setBeginIndex(int beginIndex) {
		
		this.beginIndex = (currentPage-1)*pageSize;//分页查询的索引
	}
	public int getPriviousPage() {
		
		return priviousPage;
	}

	public void setPriviousPage(int priviousPage) {
		if (currentPage-1<=1) {
			this.priviousPage=1;
		}else {
			this.priviousPage= currentPage-1;
		}
	}

	public int getNextPage() {
		
		return this.nextPage;
		
	}

	public void setNextPage(int nextPage) {
		if (currentPage+1>totalPage) {
			this.nextPage=totalPage;
		}else {
			this.nextPage = currentPage+1;
		}
		
	}
}
